import useLoading from "./loading";
const { loading, setLoading } = useLoading(true);
import { deleteModal } from "@/hooks/deleteModal";

// 获取列表
export const queryList = async (apiMethod) => {
  setLoading(true);
  try {
    var { data } = await apiMethod;
  } finally {
    setLoading(false);
  }
  return { data, loading };
};

const handleDelete = (record) => {
  deleteModal(`确定要删除当前数据-[${record?.name}]`, async () => {
    try {
      await editTable(`${apiUrl.value}${record?.id}/`);
      Message.success("删除成功");
      fetchData();
    } catch (err) {
      console.log(err);
    }
  });
};